﻿#pragma once

#include <QObject>

#include "TurnTableCodec.h"

class TurnTableRunningStateManager : public QObject
{
  Q_OBJECT
public:

private:
  //供外部使用的状态位，geter and seter在本头文件末尾-----------------------------------------------------------------
  TurnTableCodec::TurnTableLoadMode state_turnTable_loadMode = TurnTableCodec::Mode_Loaded;//负载状态位
  TurnTableCodec::TargetState state_turnTable_isPositionReached = TurnTableCodec::State_NotReached;//位置是否达到状态位
  TurnTableCodec::TargetState state_turnTable_isRateReached = TurnTableCodec::State_NotReached;//速率是否达到状态位
  TurnTableCodec::TargetState state_turnTable_isStopReached = TurnTableCodec::State_NotReached;//停止是否达到状态位
  TurnTableCodec::TurnTablePowerSupplyState state_turnTable_powerSupplyState = TurnTableCodec::State_PowerOff; //转台电源供应状态位
  TurnTableCodec::TurnTableCircuitState state_turnTable_circuitState = TurnTableCodec::State_CircuitOpened; //转台电路状态位
  TurnTableCodec::TurnTableAmplifierState state_turnTable_amplifierState = TurnTableCodec::State_AmplifierNormal; //转台功放机状态位
  TurnTableCodec::TurnTableRunningState state_turnTable_runningState = TurnTableCodec::State_TurnTableStoped;//转台运行状态位
  TurnTableCodec::TurnTableSearchZeroState state_turnTable_searchZeroState = TurnTableCodec::State_NotSearch;//转台寻零状态位
  TurnTableCodec::TurnTableRunningMode state_turnTable_runningMode = TurnTableCodec::Mode_RateMode;//转台运行模式状态位

  float state_turnTable_currentPosition = 0;//转台当前位置
  float state_turnTable_currentRate = 0;//转台当前速率
  float state_turnTable_targetPosition = 0;//目标位置
  float state_turnTable_targetRate = 0;//目标速率
  float state_turnTable_targetAcceleration = 0;//目标加速度

  float state_thermostat_currentTemperature = 0;//温箱当前温度
  float state_thermostat_targetTemperature = 0;//温箱目标温度
  float state_thermostat_temperatureRate = 0;//温箱变温速率
  //----------------------------------------------------------------------------------------------------------------------------

  TurnTableCodec* turnTableCodec = Q_NULLPTR;
public:
  TurnTableRunningStateManager(QObject* parent = Q_NULLPTR);
  ~TurnTableRunningStateManager();
  //以下私有槽函数是配合转台解码器使用的，请勿乱动
private slots:
  void slot_recordTurnTableRunningState(TurnTableCodec::TurnTableInstructionFlag instructionFlag, float arg1, float arg2, float arg3);
  void slot_setTurnTableCurrentState(float position, float rate);
  void slot_setTurnTableSearchZeroState(TurnTableCodec::TurnTableSearchZeroState turnTableSearchZeroState);
  void slot_setTurnTableTargetPositionState(TurnTableCodec::TargetState targetState);
  void slot_setTurnTableTargetRateState(TurnTableCodec::TargetState targetState);
  void slot_setTurnTableTargetStopState(TurnTableCodec::TargetState targetState);
  void slot_setTurnTablePowerSupplyState(TurnTableCodec::TurnTablePowerSupplyState turnTablePowerSupplyState);
  void slot_setTurnTableCircuitState(TurnTableCodec::TurnTableCircuitState turnTableCircuitState);
  void slot_setTurnTableAmplifierState(TurnTableCodec::TurnTableAmplifierState turnTableAmplifierState);
  void slot_setTurnTableRunningState(TurnTableCodec::TurnTableRunningState turnTableRunningState);
  void slot_setCurrentThermostatTemperature(float temperature);

  //geter
public:
  TurnTableCodec::TurnTableLoadMode getState_turnTable_loadMode();
  TurnTableCodec::TargetState getState_turnTable_isPositionReached();
  TurnTableCodec::TargetState getState_turnTable_isRateReached();
  TurnTableCodec::TargetState getState_turnTable_isStopReached();
  TurnTableCodec::TurnTablePowerSupplyState getState_turnTable_powerSupply();
  TurnTableCodec::TurnTableCircuitState getState_turnTable_circuit();
  TurnTableCodec::TurnTableAmplifierState getState_turnTable_amplifier();
  TurnTableCodec::TurnTableRunningState getState_turnTable_running();
  TurnTableCodec::TurnTableSearchZeroState getState_turnTable_searchZero();
  TurnTableCodec::TurnTableRunningMode getState_turnTable_runningMode();
  float getState_turnTable_currentPosition();
  float getState_turnTable_currentRate();
  float getState_turnTable_targetPosition();
  float getState_turnTable_targetRate();
  float getState_turnTable_targetAcceleration();
  float getState_thermostat_currentTemperature();
  float getState_thermostat_targetTemperature();
  float getState_thermostat_temperatureRate();
  TurnTableCodec* getTurnTableCodec();
  void setTurnTableCodec(TurnTableCodec* turnTableCodec);
};
